// 导入公共的css和js
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/css/main.css'
import './assets/fonts/iconfont.css'
import ZkTable from 'vue-table-with-tree-grid'
import axios from 'axios'
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/';
//导入进度条插件
import NProgress from 'nprogress'
//导入进度条样式
import 'nprogress/nprogress.css'
// 副本文编辑器
import VueQuillEditor from 'vue-quill-editor'

// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor, /* { default global options } */)
// 
Vue.component('tree-table', ZkTable);

// 请求拦截器
axios.interceptors.request.use(config => {
  // console.log(config);
  // 开始请求的时候打开拦截器
  NProgress.start();
  config.headers.Authorization = sessionStorage.getItem('token');
  return config
})
// 响应拦截器
axios.interceptors.response.use(res=>{
  // 响应成功关闭进度条
  NProgress.done();
  return res.data;
})
// 将axios挂载到Vue的原型中
Vue.prototype.axios = axios;
Vue.config.productionTip = false;
// 时间过滤器写在vue实例之前
Vue.filter('formData',function(time){
  var date=new Date(time);
  var y=(date.getFullYear()+"").padStart(2,0);
  var m=(date.getMonth()+1+"").padStart(2,0);
  var d=(date.getDate()+"").padStart(2,0);
  return `${y}-${m}-${d}`
});
// $mount('#app')和静态资源中index.html的#app绑定的
new Vue({
  router,
  // 渲染并替换到App.vue指定位置
  render: h => h(App)
}).$mount('#app')